package cn.wolfcode.shop.server.service.impl;

import cn.wolfcode.shop.api.domain.OrderAction;
import cn.wolfcode.shop.api.domain.OrderInfo;
import cn.wolfcode.shop.api.service.IOrderActionService;
import cn.wolfcode.shop.server.mapper.OrderActionMapper;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;


@Service
public class OrderActionServiceImpl implements IOrderActionService{
    @Autowired
    private OrderActionMapper orderActionMapper;

    @Override
    public int save(OrderAction orderAction) {
        return orderActionMapper.insert(orderAction);
    }

    @Override
    public List<OrderAction> selectActionByOrderId(Long orderId) {
        return orderActionMapper.selectActionByOrderId(orderId);
    }

    @Override
    public void createAction(OrderInfo orderInfo, String remark) {
        OrderAction orderAction = new OrderAction();
        orderAction.setActionUser(orderInfo.getConsignee());
        orderAction.setOrderId(orderInfo.getId());
        orderAction.setOrderStatus(orderInfo.getOrderStatus());
        orderAction.setPayStatus(orderInfo.getPayStatus());
        orderAction.setShippingStatus(orderInfo.getShippingStatus());
        orderAction.setActionTime(new Date());
        orderAction.setActionPlace((byte) 1);
        orderAction.setActionNote(remark);
        orderActionMapper.insert(orderAction);
    }
}
